import http from '@/utils/request.js'
import API from '@/config/api.config'

// 用户服务接口
const orderService = {
  // 用户登录
  create: name => http.request({
    url:API.order.create,
    method: 'POST',
    data: { name }
  }),

  upload_record: tempFilePath => {
    //同时上传文件和表单数据
    const formData = getApp().globalData.order
    return http.uploadFile({
      url:API.order.upload_record,
      filePath: tempFilePath,
      name:'record',
      formData: formData
    })
  },

  update: data => http.request({
    url:API.order.update,
    method: 'POST',
    data
  }),
  
  list_user_id: () => http.request({
    url:API.order.list_user_id,
    method: 'GET',
  }),

  getDetail: id => http.request({
    url:API.order.id,
    method: 'GET',
    data: { id } 
  }),

  pay: data => http.request({
    url:API.order.pay,
    method: 'POST',
    data
  }),

  status: data => http.request({
    url:API.order.status,
    method: 'POST',
    data
  }),

  statistics: () => http.request({
    url:API.order.statistics,
    method: 'GET',
  }),

  wechat_pay: (id, total_price) => http.request({
    url:API.order.wechat_pay,
    method: 'POST',
    data:{
      id,
      total_price
    }
  }),
  check_pay_status: id => http.request({
    url:API.order.check_pay_status,
    method: 'GET',
    data:{
      id
    } 
  })
};

export default orderService